#include "SPI.H"

void SPI_Init(void)
{
    NRF_SCK = 0;
    NRF_CSN = 1;
    NRF_CE  = 0;
    NRF_IRQ = 1;
}

unsigned char SPI_RW(unsigned char dat)
{
    unsigned char bit_ctr;
    for(bit_ctr = 0; bit_ctr < 8; bit_ctr++)
    {
        if(dat & 0x80)
            NRF_MOSI = 1;
        else
            NRF_MOSI = 0;
        dat = (dat << 1);
        NRF_SCK = 1;
        dat |= NRF_MISO;
        NRF_SCK = 0;
    }
    return dat;
}
